#ifndef __USERMANAGER_H__
#define __USERMANAGER_H__

#include <mutex>
#include <fstream>
#include <vector>

#include "userInfo.h"

#define UAPP UserManager::getInstance()

class UserManager
{
public:
    static UserManager* getInstance();
    ~UserManager();

    bool isUserExists(const std::string& userId);
    int lastUserId();
    void addUser(const UserInfo& d);

private:
    UserManager();

private:
    static UserManager*         m_self;
    static std::mutex           m_selfMutex;

    std::fstream                m_userHandle;
    std::vector<UserInfo>       m_userData;
    int                         m_lastUserId;
};

#endif //__USERMANAGER_H__